package logic

import (
	"context"
	"meituan-waimai/meituanrpc/meituanrpc"

	"meituan-waimai/api/internal/svc"
	"meituan-waimai/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type MerchantStatisticsLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewMerchantStatisticsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MerchantStatisticsLogic {
	return &MerchantStatisticsLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *MerchantStatisticsLogic) MerchantStatistics(req *types.MerchantStatisticsRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	statistics, err := l.svcCtx.MeiTuanRpc.MerchantStatistics(l.ctx, &meituanrpc.MerchantStatisticsRequest{MerchantId: req.MerchantId})
	if err != nil {
		return &types.Response{
			Code: -1,
			Msg:  "查询数据统计失败",
			Data: err.Error(),
		}, nil
	}
	return &types.Response{
		Code: -1,
		Msg:  "查询数据统计成功",
		Data: statistics,
	}, nil
}
